package com.zdsoft.blp.zongbuju.shouye.bianmin.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.zdsoft.blp.R;
import com.zdsoft.blp.zongbuju.shouye.bianmin.entity.Dianhua;
import com.zdsoft.blp.zongbuju.shouye.bianmin.entity.SheQu;

import java.util.List;

/**
 * Created by Administrator on 2016/8/31.
 */
public class BMbmdhAdapter extends BaseAdapter {

    private List<Dianhua> list;
    private LayoutInflater inflater;
    private Context context;

    public BMbmdhAdapter(Context context, List list) {
        inflater = LayoutInflater.from(context);
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView == null){
            convertView = inflater.inflate(R.layout.bianmin_bmdh_item,null);
            holder = new ViewHolder();
            holder.iv_bmdz = (ImageView) convertView.findViewById(R.id.iv_bmdz);
            holder.tv_bmdz_name = (TextView) convertView.findViewById(R.id.tv_bmdz_name);
            holder.tv_bmdz_phone = (TextView) convertView.findViewById(R.id.tv_bmdz_phone);

            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        holder.iv_bmdz.setImageResource(R.drawable.wyb_wydh);
        holder.tv_bmdz_name.setText(list.get(position).getName());
        holder.tv_bmdz_phone.setText(list.get(position).getPhone());
        return convertView;
    }
    class ViewHolder{
        private ImageView iv_bmdz;
        private TextView tv_bmdz_name,tv_bmdz_phone;
    }
    public List<Dianhua> setListData(List<Dianhua> list){
        return this.list=list;
    }
}
